﻿using System;
using System.Numerics;

class Tribonacci
{
    static void Main(string[] args)
    {
        System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

        BigInteger Element1 = BigInteger.Parse(Console.ReadLine());
        BigInteger Element2 = BigInteger.Parse(Console.ReadLine());
        BigInteger Element3 = BigInteger.Parse(Console.ReadLine());

        int counter = int.Parse(Console.ReadLine());

        
        switch (counter)
        {
            case 1:
                {
                    Console.WriteLine(Element1);
                    break;
                }
            case 2:
                {
                    Console.WriteLine(Element2);
                    break;
                }
            case 3:
                {
                    Console.WriteLine(Element3);
                    break;
                }
            default:
                {
                    while (counter > 3)
                    {
                        BigInteger nextElement = Element3 + Element2 + Element1;
                        Element1 = Element2;
                        Element2 = Element3;
                        Element3 = nextElement;
                        counter--;
                    }
                    Console.WriteLine(Element3);
                    break;
                }
        }


    }
}
